What is @iconify/utils?
@iconify/utils is a utility package for working with Iconify icons. It provides various tools for managing, customizing, and converting icon data, making it easier to integrate and manipulate icons in your projects.
What are @iconify/utils's main functionalities?
Icon Data Management
This feature allows you to retrieve icon data for a specific icon. The `getIconData` function takes an icon name as an argument and returns the corresponding icon data.
const { getIconData } = require('@iconify/utils');
const iconData = getIconData('mdi:home');
console.log(iconData);
Icon Customization
This feature allows you to customize SVG content by replacing IDs to avoid conflicts. The `replaceIDs` function takes SVG content as an argument and returns the modified SVG content with unique IDs.
const { replaceIDs } = require('@iconify/utils');
const svgContent = '<svg><path id="icon" d="..."/></svg>';
const customizedSVG = replaceIDs(svgContent);
console.log(customizedSVG);
Icon Conversion
This feature allows you to convert icon data to SVG format. The `iconToSVG` function takes icon data as an argument and returns the corresponding SVG content.
const { iconToSVG } = require('@iconify/utils');
const iconData = { body: '<path d="..."/>', width: 24, height: 24 };
const svg = iconToSVG(iconData);
console.log(svg);
Other packages similar to @iconify/utils
svg-sprite
svg-sprite is a package for creating SVG sprites. It allows you to combine multiple SVG files into a single sprite, which can be used to optimize the delivery of SVG icons. Compared to @iconify/utils, svg-sprite focuses more on sprite generation rather than individual icon manipulation.
svgo
svgo is a tool for optimizing SVG files. It provides various plugins to compress and clean up SVG content, making it more efficient for web use. While @iconify/utils offers icon-specific utilities, svgo is more general-purpose and focuses on SVG optimization.
icon-gen
icon-gen is a package for generating icons for various platforms (e.g., favicon, iOS, Android) from a single source image. It is useful for creating platform-specific icons, whereas @iconify/utils is more focused on managing and customizing icon sets.
Iconify Utils
This is a set of helper functions that deal with Iconify icon sets.
Functions are split into a separate library because they are reused in many projects.
Installation
To install the library run this command:
npm install @iconify/utils --save
Documentation
Documentation is available at Iconify documentation website.
License
The library is released with MIT license.
© 2021-PRESENT Vjacheslav Trushkin